home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Workbench Add-On
/
Workbench Add-On - Volume 1.iso
/
DiskUtil
/
Crunch
/
XPK
/
DOCS
/
HFMN.DOC
< prev
next >
Wrap
Text File
|
1994-11-26
|
5KB
|
124 lines
HFMN
A fast packing & unpacking dynamic huffman
Version 1.28
Copyright © 1993/94 Martin Hauner
License/Disclaimer
------------------
This library may be freely distributed with the XPK compression package, as long
as it is kept in its original, complete, and unmodified form. It may not be
distributed by itself or in a commercial package of any kind without my
permission.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
Description
-----------
This XPK sub-library basically uses the same algorithm (dynamic huffman) as
found in the xpkHUFF.library. For more detailed information about the huffman
algorithm, take a look into HUFF.doc from M.Zimmermann -- and skip the part that
huffman compression & decompression is pretty slow !. In difference to HUFF,
HFMN is FAST on compression and decompression and produces a slightly better
output. Although the basic algorithm is the same, it is entirely different
implemented, therefore HFMN will not depack HUFF and HUFF not HFMN !
HFMN needs for private buffers (no xpkmaster.library buffers)
· 7.5 Kbyte packing memory
· 5 KByte unpacking memory
Following is a table briefly listing some comparative statistics for HFMN.
These were generated by xBench on the standard XPK benchmark system (A3000/25
with SCRAM, using the AmigaVision executeable as data) and on A4000/40 (Booting
without Startup-Sequence, with Setpatch). Note that memory needs don't include
xpkmaster.library's buffers.
Method Packing Unpacking Packing Unpacking Compression
Memory Memory Speed Speed Ratio
--------- ------- --------- ------- --------- -----------
HFMN.000+ 7.5 K 5 K 223 K/s 209 K/s 24.7
HFMN.020+ 7.5 K 5 K 259 K/s 209 K/s 24.7
and now the same with A4000/40
Method Packing Unpacking Packing Unpacking Compression
Memory Memory Speed Speed Ratio
--------- ------- --------- ------- --------- -----------
HFMN.000+ 7.5 K 5 K 537 K/s 569 K/s 24.7
HFMN.020+ 7.5 K 5 K 592 K/s 569 K/s 24.7
How does it work?
· First, i use heapsort to create the huffman tree, which is most responsible
for packing speed.
(heapsort is the second-best sort algorithm and is based upon binary trees)
· Second, (for decompression) i generate an (almost) optimal unpack code from
the huffman tree.
· Third, i save the huffman tree recursivly. That's why i need max. 320 byte
to save a complete huffman tree.
020+ Version
------------
I have experimented with 020+ code and rewrote the most used routines. My
huffman-code-translation-routine :) is reduced from 50 to 16 instructions,
and achieves a noticable speedup. (hmm, i like bitfield instructions.:-)
.next move.b (a0)+,d2 ;incoming characters ( $00-$ff )
move.l (a2,d2.w*4),d3 ;huffman code
move.b 3(a3,d2.w*4),d4 ;huffman codesize
bfins d3,(a1){d5:d4} ;store huffman code
add.l d4,d5 ;bitoffset + last codesize
dbra d7,.next
For decompression, the 020+ code produces no improvements. But there were still
some small optimizations possible, so decompression speed is improved too.
Version History
---------------
V 1.16 - first public version.
V 1.18 - 2 ways of decompression.
V 1.19 - bugfix: uncompressable data returns now XPKERR_EXPANSION
instead of XPKERR_SMALLOUTBUF.
V 1.20 - V 1.27 - some experimental versions with 020+ code.
V 1.28 - extra library with 020+ code for compression.
- improved 000+ decompression code.
Contact Address
---------------
any comments ?
email:
drizzt@trashcan.escape.de
snail-mail:
Martin Hauner
Max-Born-Straße 5
38116 Braunschweig
Germany